#!/usr/bin/python

def median(pool):
    '''Statistical median to demonstrate doctest.
    >>> median([2,9,9,7,9,2,4,5,8])
    7
    '''

    copy = sorted(pool)
    size = len(copy)
    print '------'
    print copy
    print size
    print '------'
    if size % 2 == 1:
        return copy[(size - 1) / 2]
    else :
        return (copy[size / 2 - 1] + copy[size / 2]) / 2

if __name__=='__main__':
    import doctest
    doctest.testmod()
